package com.eet.export.config;

import com.eet.export.props.ExportProperties;
import com.eet.export.service.ExportService;
import com.eet.export.service.impl.ExportServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置类
 * ConditionalOnWebApplication: 引用启动器的项目是web应用此自动配置模块才生效
 * EnableConfigurationProperties: 加载配置对象到容器
 *
 * @author Administrator
 */
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
@EnableConfigurationProperties(ExportProperties.class)
public class ExportAutoConfiguration {
    private final ExportProperties exportProperties;

    /**
     * 注入导出服务到IOC容器中
     *
     * @return 导出服务Bean
     */
    @Bean
    public ExportService exportService() {
        return new ExportServiceImpl(exportProperties);
    }
}
